package orderConsumer

import (
	"fmt"
	jsoniter "github.com/json-iterator/go"
	"newRetailByGolang/model"
	"newRetailByGolang/variable"
)

type OrderConsumer struct {

}

func NewOrderConsumer() *OrderConsumer{
	return new(OrderConsumer)
}

func (oc *OrderConsumer)ConsumerOrder() {
	for i:=1; i<=10000; i++{
		ele, err := (*variable.R).Do("lpop", variable.RMQ)
		if err != nil {
			fmt.Println("no msg.sleep now：", err)
		} else {
			if ele != nil {
				var o model.Order
				jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(ele.([]byte), &o)
				fmt.Println(o.GoodId)
				fmt.Println(o.GoodName)
				fmt.Println("-------------------------------------------------------------------------------")
			}else {
				continue
			}
		}
	}
}
